﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;

using Wuqi.Webdiyer;

using DreamBuilder.Common;
using xHubble.SingleWell.DataAccess;
using HubbleDataAccess;

namespace Web.Views.SingleWellManage
{
    public partial class ArchiveGlobalSearch : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            aspNetPagerSearch.PageSizeChanging += new EventHandler(pagerTransfered_PageSizeChanging);
        }

        protected void pagerTransfered_PageSizeChanging(object sender, EventArgs e)
        {
            SearchData();
        }

        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            this.aspNetPagerSearch.CurrentPageIndex = 1;
            SearchData();
        }

        private void SearchData()
        {
            string searchKeywords = this.txtSearchKeyword.Value;
            if (searchKeywords == "- 可输入井号题名施工措施井别档号全宗号以及明细查询 -")
                searchKeywords = "";
            PageInfo pageinfo = new PageInfo();
            pageinfo.PageIndex = this.aspNetPagerSearch.CurrentPageIndex;
            pageinfo.PageSize = this.aspNetPagerSearch.PageSize;
            DataTable singlewellTable = SingleWellDAL.SearchSinglewell(searchKeywords, pageinfo);
            gv_SingleWellList.DataSource = singlewellTable;
            gv_SingleWellList.DataBind();
            this.aspNetPagerSearch.RecordCount = pageinfo.RecordCount;
        }

        protected void aspNetPagerSearch_PageChanging(object sender, PageChangingEventArgs e)
        {
            aspNetPagerSearch.CurrentPageIndex = e.NewPageIndex;
            SearchData();
        }
    }
}